/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * jifConsultarSuministroProveedor.java
 *
 * Created on 15-dic-2010, 18:31:14
 */

package Proveedores;

import administracion.delegate.GestionPedidosDelegate;
import administracion.helper.Utiles_Tabla;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.jdesktop.beansbinding.AutoBinding;
import org.jdesktop.beansbinding.BindingGroup;
import org.jdesktop.beansbinding.ELProperty;
import org.jdesktop.swingbinding.JTableBinding;
import org.jdesktop.swingbinding.SwingBindings;
import suministros.ejb30.TO.ProveedorSuministroTO;

/**
 *
 * @author Diana
 */
public class jifConsultarSuministroProveedor extends javax.swing.JInternalFrame {
    private BindingGroup bindingGroup;
    private JTableBinding jTableBinding;

    /** Creates new form jifConsultarSuministroProveedor */
    public jifConsultarSuministroProveedor() {
        initComponents();
        this.actualizarTabla();
    }
   public void actualizarTabla(){
       List<ProveedorSuministroTO> lista= new ArrayList<ProveedorSuministroTO>();
        try {
           lista = GestionPedidosDelegate.getInstance().listaProveedorSuministro();
        } catch (Exception ex) {
            Logger.getLogger(jifConsultarSuministroProveedor.class.getName()).log(Level.SEVERE, null, ex);
        }
    this.bindingGroup = new BindingGroup();
    this.jTableBinding = SwingBindings.createJTableBinding(AutoBinding.UpdateStrategy.READ, lista, this.jTable1);

    JTableBinding.ColumnBinding columnBinding0 = this.jTableBinding.addColumnBinding(ELProperty.create("${ruc}"));

    columnBinding0.setColumnName("RUC");
    columnBinding0.setColumnClass(String.class);
    columnBinding0.setEditable(false);

    JTableBinding.ColumnBinding columnBinding1 = this.jTableBinding.addColumnBinding(ELProperty.create("${razon}"));

    columnBinding1.setColumnName("RAZON SOCIAL");
    columnBinding1.setColumnClass(String.class);
    columnBinding1.setEditable(false);

    JTableBinding.ColumnBinding columnBinding11 = this.jTableBinding.addColumnBinding(ELProperty.create("${suministro}"));

    columnBinding11.setColumnName("SUMINISTRO");
    columnBinding11.setColumnClass(String.class);
    columnBinding11.setEditable(false);

    JTableBinding.ColumnBinding columnBinding2 = this.jTableBinding.addColumnBinding(ELProperty.create("${precio}"));

    columnBinding2.setColumnName("PRECIO");
    columnBinding2.setColumnClass(BigDecimal.class);
    columnBinding2.setEditable(false);




    this.bindingGroup.addBinding(this.jTableBinding);
    this.bindingGroup.bind();
     try {
         int[] porcentajes= {15,55,15,15};
          Utiles_Tabla.definirAnchoColumnasJTable(this.jTable1, porcentajes);
          // MiTablePrint.autoSizeTableColumns(jtDetalleSuministro);
        } catch (Exception ex) {
            Logger.getLogger(jifConsultarSuministroProveedor.class.getName()).log(Level.SEVERE, null, ex);
        }

    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jScrollPane1 = new javax.swing.JScrollPane();
        jTable1 = new javax.swing.JTable();
        jbCancelar = new javax.swing.JButton();

        setTitle("PRECIO SUMINISTROS POR PROVEEDOR");

        jTable1.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "RUC", "RAZON", "PRECIO"
            }
        ));
        jScrollPane1.setViewportView(jTable1);

        jbCancelar.setFont(new java.awt.Font("Arial", 1, 12)); // NOI18N
        jbCancelar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/iconoscomb/16x16ozygen/actions/button_cancel.png"))); // NOI18N
        jbCancelar.setText("Cerrar");
        jbCancelar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbCancelarActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 522, Short.MAX_VALUE))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(212, 212, 212)
                        .addComponent(jbCancelar)))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 259, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 9, Short.MAX_VALUE)
                .addComponent(jbCancelar))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jbCancelarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbCancelarActionPerformed

        int res = javax.swing.JOptionPane.showConfirmDialog( this,"Esta seguro de salir?",
                "Confirmar",javax.swing.JOptionPane.YES_NO_OPTION );
        if(res==javax.swing.JOptionPane.YES_OPTION){
            this.dispose();
        }
    }//GEN-LAST:event_jbCancelarActionPerformed


    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JTable jTable1;
    private javax.swing.JButton jbCancelar;
    // End of variables declaration//GEN-END:variables

}
